<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:gb="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Faq" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="faq" />
	</ui:define>

	<ui:define name="content">

		<script type="text/javascript"
			src="#{request.contextPath}/scripts/it_editor.js"></script>

		<script language="javascript" type="text/javascript"
			src="#{request.contextPath}/scripts/tiny_mce/tiny_mce.js"></script>

		<h:form>

			<p:messages id="messages" />
			<gb:center>
				<p:panel header="Gestione Faq">
					<h:panelGrid columns="2" style="width: 95%">

						<h:outputLabel value="Categoria(*):" for="categoryId" />
						<h:selectOneMenu id="categoryId" style="width: 100%;"
							value="#{faqController.element.faqCategory.id}" required="true">
							<f:selectItems value="#{faqCategoryItems}" />
						</h:selectOneMenu>

						<h:outputLabel for="dataInsert" value="Data inserimento:" />
						<p:calendar id="dataInsert" value="#{faqController.element.date}"
							pattern="dd/MM/yyyy" timeZone="Europe/Rome" />

						<h:outputLabel for="question" value="Domanda:" />
						<h:inputTextarea id="question" cols="20" rows="20"
							value="#{faqController.element.question}"
							style="height: 166px; width: 100%;" />


						<h:outputLabel for="answer" value="Riposta:" />
						<h:inputTextarea value="#{faqController.element.answer}"
							id="answer" style=" height : 166px; width: 100%;" />

					</h:panelGrid>
					<br />
				</p:panel>

				<h:panelGrid columns="4">

					<h:commandButton action="#{faqController.save}" value="Salva"
						immediate="false" rendered="#{not faqController.editMode}" />

					<h:commandButton action="#{faqController.update}"
						value="Salva le modifiche" immediate="false"
						rendered="#{faqController.editMode}" />

					<h:commandButton action="#{faqController.delete}" value="Elimina"
						rendered="#{faqController.editMode}" immediate="true"
						onclick="if (!confirm('Vuoi davvero eliminare?')) return false" />
				</h:panelGrid>
			</gb:center>
		</h:form>

	</ui:define>
</ui:composition>